package cn.iocoder.yudao.module.biz.dal.mysql.operationTicket;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.biz.dal.dataobject.operationTicket.BizOperationTicketDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.biz.controller.admin.operationTicket.vo.*;

/**
 * 操作票 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface BizOperationTicketMapper extends BaseMapperX<BizOperationTicketDO> {

    default PageResult<BizOperationTicketDO> selectPage(BizOperationTicketPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BizOperationTicketDO>()
                .likeIfPresent(BizOperationTicketDO::getName, reqVO.getName())
                .likeIfPresent(BizOperationTicketDO::getDeptName, reqVO.getDeptName())
                .eqIfPresent(BizOperationTicketDO::getType, reqVO.getType())
                .eqIfPresent(BizOperationTicketDO::getSendPeople, reqVO.getSendPeople())
                .eqIfPresent(BizOperationTicketDO::getOperator, reqVO.getOperator())
                .eqIfPresent(BizOperationTicketDO::getGuardian, reqVO.getGuardian())
                .betweenIfPresent(BizOperationTicketDO::getStartTime, reqVO.getBeginStartTime(), reqVO.getEndStartTime())
                .betweenIfPresent(BizOperationTicketDO::getEndTime, reqVO.getBeginEndTime(), reqVO.getEndEndTime())
                .eqIfPresent(BizOperationTicketDO::getImage, reqVO.getImage())
                .betweenIfPresent(BizOperationTicketDO::getCrateTime, reqVO.getBeginCrateTime(), reqVO.getEndCrateTime())
                .eqIfPresent(BizOperationTicketDO::getDeptId, reqVO.getDeptId())
                .orderByDesc(BizOperationTicketDO::getId));
    }

    default List<BizOperationTicketDO> selectList(BizOperationTicketExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<BizOperationTicketDO>()
                .likeIfPresent(BizOperationTicketDO::getName, reqVO.getName())
                .likeIfPresent(BizOperationTicketDO::getDeptName, reqVO.getDeptName())
                .eqIfPresent(BizOperationTicketDO::getType, reqVO.getType())
                .eqIfPresent(BizOperationTicketDO::getSendPeople, reqVO.getSendPeople())
                .eqIfPresent(BizOperationTicketDO::getOperator, reqVO.getOperator())
                .eqIfPresent(BizOperationTicketDO::getGuardian, reqVO.getGuardian())
                .betweenIfPresent(BizOperationTicketDO::getStartTime, reqVO.getBeginStartTime(), reqVO.getEndStartTime())
                .betweenIfPresent(BizOperationTicketDO::getEndTime, reqVO.getBeginEndTime(), reqVO.getEndEndTime())
                .eqIfPresent(BizOperationTicketDO::getImage, reqVO.getImage())
                .betweenIfPresent(BizOperationTicketDO::getCrateTime, reqVO.getBeginCrateTime(), reqVO.getEndCrateTime())
                .eqIfPresent(BizOperationTicketDO::getDeptId, reqVO.getDeptId())
                .orderByDesc(BizOperationTicketDO::getId));
    }

}
